package com.yanqu.road.server.cmd.activity.liondance;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LionDanceProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.liondance.CrossLionDanceActivityMgr;
import com.yanqu.road.server.manager.activity.liondance.LionDanceActivity;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C_LION_DANCE_GIVE_APPLY_CARD_BACK, desc = "赠送卡片（返回）")
public class CrossLionDanceApplyHandleBackCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        LionDanceProto.CrossLionDanceApplyHandleRespMsg respMsg = LionDanceProto.CrossLionDanceApplyHandleRespMsg.parseFrom(packet.getBytes());
        if(respMsg.getRet() == 0){
            LionDanceActivity activity = CrossLionDanceActivityMgr.getLionDanceActivity(respMsg.getActivityId());
            if(activity != null){
                activity.cancelApplyCard(respMsg.getToUserId(), respMsg.getApplyNo());
            }
        }
        MessageHelper.sendPacket(respMsg.getFromServerId(), respMsg.getFromUserId(), YanQuMessageUtils.buildMessage(Protocol.S_LION_DANCE_GIVE_FRIEND_BACK_FROM_CROSS, respMsg.toBuilder()));

    }

    @Override
    public void sendData() {

    }
}
